package com.zx.idc.backend.gui.network;


import com.baomidou.mybatisplus.plugins.Page;
import com.zx.idc.backend.gui.common.BaseApi;
import com.zx.idc.backend.gui.common.Result;
import com.zx.idc.ds.network.entity.NetVpnInfo;
import com.zx.idc.ds.network.service.INetVpnInfoService;
import com.zx.idc.ds.network.vo.NetVpnInfoVo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * VPN信息表 前端控制器
 * </p>
 *
 * @author rxliuli
 * @since 2019-04-25
 */
@RestController
@RequestMapping("/api/netVpnInfo")
public class NetVpnInfoController extends BaseApi {
    @Autowired
    private INetVpnInfoService iNetVpnInfoService;

    @GetMapping("/query-page")
    @RequiresPermissions("network-configuration:net-vpn-info")
    public Result<Page<NetVpnInfoVo>> queryPage(Page<NetVpnInfoVo> page, NetVpnInfoVo netVpnInfoVo) {
        return success(iNetVpnInfoService.queryPage(page, netVpnInfoVo));
    }

    @PostMapping("/add")
    @RequiresPermissions("network-configuration:net-vpn-info:edit")
    public Result<Boolean> add(@RequestBody NetVpnInfo netVpnInfo) {
        return build(iNetVpnInfoService.insert(netVpnInfo));
    }

    @PostMapping("/delete/batch")
    @RequiresPermissions("network-configuration:net-vpn-info:edit")
    public Result<Boolean> add(@RequestBody List<String> ids) {
        return build(iNetVpnInfoService.deleteBatchIds(ids));
    }

    @PostMapping("/delete/{id}")
    @RequiresPermissions("network-configuration:net-vpn-info:edit")
    public Result<Boolean> deleteOne(@PathVariable("id") Integer id) {
        return build(iNetVpnInfoService.deleteById(id));
    }

    @PostMapping("/update")
    @RequiresPermissions("network-configuration:net-vpn-info:edit")
    public Result<Boolean> update(@RequestBody NetVpnInfo netVpnInfo) {
        return build(iNetVpnInfoService.updateById(netVpnInfo));
    }

}

